package com.mbl.base.modular.base.controller;


import com.mbl.base.core.common.controller.BaseController;
import com.mbl.base.core.common.dto.MblResult;
import com.mbl.base.modular.base.entity.Role;
import com.mbl.base.modular.base.service.IRoleService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lwj
 * @since 2020-02-24
 */
@RestController
@RequestMapping("/base/role")
public class RoleController extends BaseController<Role, IRoleService> {

    @GetMapping("/options")
    public Object options() {
        List<Role> roleList = getService().list();

        List<Map<String, Object>> options = new ArrayList<>(roleList.size());
        for (Role role : roleList) {
            Map<String, Object> option = new HashMap<>(2);
            option.put("value", role.getId());
            option.put("label", role.getName());
            options.add(option);
        }
        return MblResult.success(options);
    }
}

